home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mikecom / stat.asm < prev    next >
Assembly Source File  |  1987-05-16  |  2KB  |  58 lines

  1.  
  2. title GET STATUS INFORMATION
  3. include subfx.h
  4.  
  5. ;  Mike Dumdei,  6 Holly Lane,  Texarkana TX 75503
  6.  
  7. ;******************************************************************************
  8. ; ASYNC_STAT -- Returns STAT1 in AH & STAT2 in AL after the mask passed by
  9. ;               the function call is applied (STAT1;STAT2 && StatMask).
  10. ;               Bit 5 of stat1 is not used by the stat function -- instead
  11. ;               returns R_NOPORT if invalid port.
  12. ;Bit maps of status bytes:
  13. ;-- Values returned by async_stat (1 & 2) and async_rx high byte (1 only)
  14. ;   STAT1: 0=rx bufr ovrfl   1=char overrun     2=parity err    3=framing err
  15. ;          4=break intrpt    5=invalid port     6=rx bufr empty 7=no carrier
  16. ;   STAT2: 0=XON/OFF in use  1=XOFF received    2=XOFF sent     3=tx buf empty
  17. ;          4=montr'g CTS     5=montr'g DSR      6=flw hlt actv  7=montr'g CD
  18. ;******************************************************************************
  19.  
  20. begseg          COMM_TEXT
  21. publicproc      _async_stat
  22.         push    bp
  23.         mov     bp,sp
  24.         push    si              ;stack frame setup
  25.         call    __ck_port_arg   ;ck if valid, load pointers
  26.         jz      stat_exit       ;bad arg if ZR flag set
  27.         mov     bh,STAT1        ;get STAT1 byte
  28.         mov     ax,RX_FREE
  29.         cmp     ax,RX_SIZE      ;rx bufr empty?
  30.         jne     get_stat2
  31.         or      bh,B_RXEMPTY    ;set bit if RX bufr is empty
  32. get_stat2:
  33.         mov     bl,STAT2
  34.         mov     al,TX_STAT
  35.         and     al,FLOW_MASK
  36.         jz      get_monitrd_bits
  37.         or      bl,B_FLOWHALT   ;set bit if tx is currently stopped by flw cks
  38. get_monitrd_bits:
  39.         mov     al,MSR_MASK
  40.         not     al
  41.         or      bl,al           ;get modem signals being monitored
  42. ;ck_if_txbuf_empty:
  43.         mov     ax,TX_FREE
  44.         cmp     ax,TX_SIZE
  45.         jne     add_mask
  46.         or      bl,B_TXEMPTY    ;set bit if tx buffer is empty
  47. add_mask:
  48.         mov     ax,bx
  49.         and     ax,StatMask     ;mask off according to passed mask
  50. stat_exit:
  51.         pop     si
  52.         pop     bp
  53.         ret                     ;restore regs and exit
  54. _async_stat     endp
  55.  
  56. endseg          COMM_TEXT
  57.         end
  58.